import request from "@/utils/request";
import { R, page, PageQuery, emptyPageInfo } from "@/api/common/type";
import { RolePageResponse ,Role,AssignRole} from "@/api/role/type";

enum API {
    ROLE_PAGE_URL = "/role/roles",
    ROLE_ONE_URL = "/role/one",
    ROLE_ADD_URL = "/role/add",
    ROLE_UPDATE_URL = "/role/update",
    ROLE_DELETED_URL = "/role/delete",
    ROLE_ASSIGN_URL = "/role/assign/roles",
}
 
//获取角色分页数据
export const reqPageRoles = (data: any) => request.post<any, RolePageResponse>(API.ROLE_PAGE_URL, data)

// 获取单个角色信息
export const reqRoleOne = (id: number) => request.get<any, R<Role>>(API.ROLE_ONE_URL + `?id=` + id)

//新增角色
export const reqRoleAdd = (data: any) => request.post<any, R<boolean>>(API.ROLE_ADD_URL, data)

//编辑角色
export const reqRoleUpdate = (data: any) => request.post<any, R<boolean>>(API.ROLE_UPDATE_URL, data)

//删除角色
export const reqRoleDel = (ids: number[]) => request.post<any, R<boolean>>(API.ROLE_DELETED_URL, ids)

//用户分配角色
export const reqAssignedRole = (assignRolesDTO: AssignRole) => request.post<any, R<boolean>>(API.ROLE_ASSIGN_URL, assignRolesDTO)